class Cpanel::PhotosController < ApplicationController

  def create

    @photo = Photo.new(path: params['upload_file'])
    if @photo.save
      render json: { file_path: @photo.path.url, photo_id: @photo.id }
    end

  end

  def destroy
    if params[:product_id]
      @photo = find_product.photos.find(params[:id])
      @photo.destroy
    end
  end

  private

  def find_product
    @product = Product.find(params[:product_id])
  end


end
